﻿@using Newtouch.Infrastructure
@{
    ViewBag.Title = "RequestOfReturn";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style>
    .inline {
        width: 80%;
        display: inline;
    }

    .PriceInline {
        width: 70%;
        display: inline;
    }
</style>
<form id="form1">
    <div class="panel panel-default" style="margin-bottom:10px;">
        <div class="panel-heading">
            退药信息
        </div>
        <table class="form" style="width:98%;border:0">
            <tr>
                <td class="formTitle">退药单号：</td>
                <td class="formValue"><input type="text" id="tydh" name="tydh" class="form-control newtouch_Readonly" /></td>
                <td class="formTitle"><span class="required">*</span>退药部门：</td>
                <td class="formValue">
                    <input type="text" id="tybm" name="tybm" class="form-control" placeholder="请选择退药部门" />
                </td>
                <td class="formTitle"><span class="required">*</span>退药日期：</td>
                <td class="formValue">
                    <input type="text" id="tyrq" name="tyrq" class="form-control input-wdatepicker" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" />
                </td>
                <td class="formTitle"><span class="required">*</span>退药方式：</td>
                <td class="formValue">
                    <select class="form-control" id="fyfs" name="fyfs" onchange="ValidateForm()">
                        <option value="">==请选择==</option>
                        <option value="1">正常出库</option>
                        <option value="2">在途出库</option>
                        <option value="3">制剂出库</option>
                        <option value="4">赠送出库</option>
                        <option value="99">药事退货</option>
                    </select>
                </td>
            </tr>
        </table>
    </div>
    <div class="panel panel-default" style="margin-bottom:0;">
        <div class="panel-heading">
            药品信息
        </div>
        <table class="form" style="width:98%;border:0;" id="form2">
            <tr>
                <td class="formTitle">药品代码：</td>
                <td class="formValue">
                    <input type="hidden" id="newid" name="newid" class="form-control" />
                    <input type="text" id="srm" name="srm" class="form-control newtouch_Readonly" />
                </td>
                <td class="formTitle">批次：</td>
                <td class="formValue">
                    <input type="text" id="pc" name="pc" class="form-control newtouch_Readonly" />
                </td>
                <td class="formTitle">有效期：</td>
                <td class="formValue">
                    <input type="text" id="yxq" name="yxq" class="form-control newtouch_Readonly" />
                </td>
                <td class="formTitle">退药数量：</td>
                <td class="formValue">
                    <div class="row">
                        <div class="col-md-8">
                            <input id="tysl" name="tysl" type="text" class="form-control newtouch_Readonly" />
                        </div>
                        <div class="col-md-4">
                            <select id="ty_dw" class="form-control newtouch_Readonly" style="background-color:rgb(238,238,238)"></select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="formTitle">药品名称：</td>
                <td class="formValue"><input type="text" id="ypmc" class="form-control newtouch_Readonly" /></td>
                <td class="formTitle">规格：</td>
                <td class="formValue"><input type="text" id="gg" class="form-control newtouch_Readonly" /></td>
                <td class="formTitle">可退数量：</td>
                <td class="formValue">
                    <input type="text" id="kykc" class="form-control newtouch_Readonly inline" />
                    <label id="kykc_dw"></label>
                </td>
                <td class="formTitle">生产厂家：</td>
                <td class="formValue"><input type="text" id="sccj" class="form-control newtouch_Readonly" /></td>
            </tr>
            <tr>
                <td class="formTitle">批发价：</td>
                <td class="formValue">
                    <input type="text" id="pfj" class="form-control newtouch_Readonly PriceInline" />
                    <label id="pf_dw">元/瓶</label>
                </td>
                <td class="formTitle">零售价：</td>
                <td class="formValue">
                    <input type="text" id="lsj" class="form-control newtouch_Readonly PriceInline" />
                    <label id="ls_dw">元/瓶</label>
                </td>
                <td class="formTitle">批发金额：</td>
                <td class="formValue">
                    <input type="text" id="pfje" class="form-control newtouch_Readonly inline" />
                    <label>元</label>
                </td>
                <td class="formTitle">零售金额：</td>
                <td class="formValue">
                    <input type="text" id="lsje" class="form-control newtouch_Readonly inline" />
                    <label>元</label>
                </td>
            </tr>
        </table>
        <input type="hidden" id="ph" />
        <input type="hidden" id="ypdm" />
        <input type="hidden" id="zxsl" />
        <input type="hidden" id="zhyz" />
        <input type="hidden" id="yplb" />
        <input type="hidden" id="ykdw" />
        <input type="hidden" id="zxdw" />
    </div>
</form>
@Html.Partial("_MiddleButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel()
{
    ShowKeyList = new int[] { 2, 3, 6, 9 },
    F2Text = "添加",
    F3Text = "修改",
    F6Text = "删除",
    F9Text = "取消修改",
    F9Hidden = true
})
<div class="gridPanel" style="margin-top:10px">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
@Html.Partial("_BottomButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel
{
    ShowKeyList = new int[] { 7, 8 },
    F7Text = "新退药单",
    F8Text = "退药"
})
<script type="text/javascript">
    var dtdw;
    var globalpc;
    var newxmList = [];   //新项目List
    var editingNewid = null;    //正在修改的行
    var dw = "";

    $(function () {
        $(window).resize(function () {
            window.initLayout("MyTabGrid");
        });
        init();
        fillDataToGrid();
    });
    
    //初始化
    function init() {
        GetDjh();
        bottomButtonsReset();
        $("#ty_dw").change(function () {
            dw = $(this).find("option:selected").text();
        });
        ///初始化输入码
        $("#srm").newtouchBatchFloatingSelector({
            clickautotrigger: true,
            height: 350,
            width: 1100,
            url: "/DrugStorage/SelectDepartmentMedicineList",
            ajaxmethod: 'POST',
            ajaxreqdata: function () {
                var reqData = {};
                reqData.rkbm = $("#tybm").val();
                reqData.keyword = $.trim($("#srm").val());
                return reqData;
            },
            caption: "输入码",
            colModel: [
            { label: '类别', name: 'yplb', width: 50 },
            { label: '代码', name: 'ypCode', width: 100 },
            { label: '名称', name: 'ypmc', width: 200, align: 'left' },
            { label: '规格', name: 'gg', width: 100, align: 'left' },
            { label: '库存', name: 'xykcstr', width: 70 },
            { label: '单位', name: 'ykdw', width: 60 },
            { label: '厂家', name: 'sccj', width: 200, align: 'left' },
            { label: '批准文号', name: 'pzwh', width: 150, align: 'left' },
            { label: '零售价', name: 'lsj', width: 70 },
            { label: '批发价', name: 'pfj', width: 70 },
            { label: 'bzs', name: 'bzs', hidden: true },
            { label: 'zxdw', name: 'zxdw', hidden: true },
            { label: 'xykc', name: 'xykc', hidden: true }
            ],
            itemdbclickhandler: function ($thistr) {
                var ykdw = $thistr.attr('data-ykdw');
                $("#ypdm").val($thistr.attr('data-ypCode'));
                $("#ypmc").val($thistr.attr('data-ypmc'));
                $("#srm").val($thistr.attr('data-ypCode'));
                $("#gg").val($thistr.attr('data-gg'));
                $("#sccj").val($thistr.attr('data-sccj'));
                $("#pf_dw").html("元/" + ykdw);
                $("#ls_dw").html("元/" + ykdw);
                //$("#ph").val($thistr.attr('data-ph'));
                //$("#pc").val($thistr.attr('data-pc'));
                //$("#kykc").val($thistr.attr('data-bzdwsl'));
                $("#kykc_dw").html(ykdw);
                $("#lsj").val($thistr.attr('data-lsj'));
                $("#pfj").val($thistr.attr('data-pfj'));
                //$("#yxq").val($thistr.attr('data-yxq'));
                //$("#zxsl").val($thistr.attr('data-zxsl'));
                //$("#zhyz").val($thistr.attr('data-zhyz'));
                $("#yplb").val($thistr.attr('data-yplb'));
                $("#ty_dw").find("option").remove();
                $("#ykdw").val(ykdw);
                $('#ty_dw').append('<option value="ykdw">' + ykdw + '</option>');
                $("#tysl").val("");
                $("#pc").val("");
                var list = new Array();
                list.push({ id: 'pc' });
                readonly(list, 2)

                //初始化药品批次
                $("#pc").newtouchBatchFloatingSelector({
                    height: 300,
                    width: 560,
                    clickautotrigger: true,
                    url: "/DrugStorage/HandOutMedicinesrmList",
                    ajaxmethod: 'POST',
                    ajaxreqdata: function () {
                        var reqData = {};
                        reqData.keyword = $.trim($("#ypdm").val());
                        reqData.ckbm = '@Constants.CurrentYfbm.yfbmCode';
                        return reqData;
                    },
                    caption: "批次",
                    colModel: [
                        //{ label: '药品名称', name: 'ypmc', width: 100, align: 'left' },
                        { label: '批次', name: 'pc', width: 150, align: 'left' },
                        { label: '批号', name: 'ph', width: 150, align: 'left' },                        
                        { label: '库存', name: 'bzdwsl', width: 100, align: 'left' },
                        { label: '有效期', name: 'yxq', width: 150, formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }, align: 'left' },
                        { label: '转换因子', name: 'zhyz', hidden: true },
                        { label: '部门单位', name: 'bmdw', hidden: true },
                        { label: '药品代码', name: 'ypdm', hidden: true },
                        { label: '最小库存', name: 'zxsl', hidden: true },
                        { label: '最小单位', name: 'zxdw', hidden: true },
                        { label: '系数', name: 'bzs', hidden: true },
                        { label: '包装单位', name: 'bzdw', hidden: true },
                        { label: '转换成部门单位后的最大可用数', name: 'bmdwsl', hidden: true }
                    ],
                    itemdbclickhandler: function ($thistr) {
                        $("#ph").val($thistr.attr('data-ph'));
                        $("#pc").val($thistr.attr('data-pc'));
                        $("#kykc").val($thistr.attr('data-bzdwsl'));
                        $("#yxq").val($thistr.attr('data-yxq'));
                        $("#zxsl").val($thistr.attr('data-zxsl'));
                        $("#zhyz").val($thistr.attr('data-zhyz'));
                        $("#tysl").val("");
                    }
                });
                globalpc = [];
                return;
            }
        });
        ///初始化退药部门
        $("#tybm").newtouchBatchFloatingSelector({
            clickautotrigger: true,
            height: 200,
            width: 400,
            url: "/Pharmacy/RequisitionFybmSele",
            ajaxmethod: 'POST',
            ajaxreqdata: function () {
                var reqData = {};
                reqData.keyword = $.trim($("#tybm").val());
                return reqData;
            },
            caption: "退药部门",
            colModel: [
                { label: '药房编码', name: 'yfbmCode', widthratio: 25 },
                { label: '药房名称', name: 'yfbmmc', widthratio: 25 }
            ],
            itemdbclickhandler: function ($thistr) {
                $("#tybm").val($thistr.find('td:eq(0)').html());
                return;
            }
        });
        $("#gridList").newtouchLocalDataGrid({
            height: $(window).height() - 350,
            unwritten: false,
            colModel: [
                { label: "药品类别", name: "yplb", width: 60, align: 'left' },
                { label: '药品名称', name: 'ypmc', width: 100, align: 'left' },
                { label: '规格', name: 'gg', width: 60, align: 'left' },
                { label: '批号', name: 'ph', width: 100, align: 'left' },
                { label: '批次', name: 'pc', width: 100, align: 'left' },
                { label: '有效期', name: 'yxq', width: 70, align: 'left' },
                { label: '生产厂家', name: 'sccj', width: 100, align: 'left' },
                { label: '库存', name: 'kykc', width: 55, align: 'right' },
                { label: '退药数量', name: 'tysl', width: 55, align: 'right' },
                { label: '单位', name: 'dw', width: 40, align: 'left' },
                { label: '批发价', name: 'pfj', width: 60, align: 'right' },
                { label: '零售价', name: 'lsj', width: 60, align: 'right' },
                { label: '批发总价', name: 'pfje', width: 70, align: 'right' },
                { label: '零售总价', name: 'lsje', width: 70, align: 'right' },
                { label: '输入码', name: 'srm', hidden: true },
                { label: "newid", name: "newid", hidden: true },
                { label: "主键", name: "ypdm", hidden: true, key: true },
                { label: "deptdw", name: "deptdw", hidden: true },
                { label: "ykdw", name: "ykdw", hidden: true },
                { label: "bzs", name: "bzs", hidden: true },
                { label: "zhyz", name: "zhyz", hidden: true }
            ],
            ondblClickRow: function (rowid) {
                gridEditRow(rowid);
            },
            onSelectRow: function (rowid) {
                $('#btn_bottombutton_f3').removeAttr('disabled');
                $('#btn_bottombutton_f6').removeAttr('disabled');
            }
        });
        $("#tysl").blur(function () {//计算批发总价和零售总价
            var tysl = Number($("#tysl").val());
            var pfje = Number($("#pfj").val()).toFixed(2);
            var lsje = Number($("#lsj").val()).toFixed(2);
            $("#pfje").val((tysl * pfje).toFixed(2));
            $("#lsje").val((tysl * lsje).toFixed(2));
        });
    }

    ///生成单据号
    function GetDjh() {
        $.ajax({
            url: "/InStorage/InitDjh",
            data: { djmc: '内部发药单', r: Math.random() },
            dataType: "json",
            async: false,
            cache: false,
            success: function (res) {
                if (res.state === "success") {
                    $("#tydh").val(res.data);
                }
                else {
                    $.modalAlert(res.message, 'error');
                }
            }
        });
    }

    //fill data to grid
    function fillDataToGrid() {
        $("#gridList").resetSelection();
        $('#gridList').jqGrid("clearGridData");
        $("#gridList").newtouchLocalDataGrid(null, newxmList);
    }

    //检查之前是否已存在添加药品
    function CheckExistPC() {
        var ypdm = $("#ypdm").val();
        var pc = $("#pc").val();
        var ph = $("#ph").val();
        for (var i = 0; i < newxmList.length; i++) {
            if (newxmList[i]["ypdm"] === ypdm && newxmList[i]["pc"] === pc && newxmList[i]["ph"] === ph) {
                $.modalAlert("该药品批次已登记，不允许新增！", 'warning');
                return false;
            }
        }
        return true;
    }

    //请求 编辑 行
    function gridEditRow(rowid) {
        if (rowid) {
            var rowData = $("#gridList").jqGrid('getRowData', rowid);
            if (rowData) {
                var rowDataArr = $.jsonWhere(newxmList, function (v) {
                    return v && v.newid === rowData.newid;
                });
                if (!rowDataArr || rowDataArr.length === 0) {
                    return; //为什么没找到
                }
                rowData = rowDataArr[0];  //通过rowData.newid从对象数组中取出该行数据
                if (true) { //&&可编辑
                    //序列化至编辑域中
                    var data = {};
                    data = JSON.stringify(rowData);
                    $("#form1").formSerialize(JSON.parse(data));
                    $('#btn_bottombutton_f6').attr('disabled', 'disabled');
                    $('#btn_bottombutton_f9').show();
                    $('#btn_bottombutton_f2').attr('disabled', 'disabled');
                    editingNewid = rowData.newid;    //正在修改的行
                }
            }
        }
    }

    //添加
    function newtouch_event_f2() {
        if (editingNewid) {
            return; //正在处于修改状态，是不能点击添加按钮的   要disable处理
        }
        if (!(checkEditingRowData() && CheckExistPC())) {    //数据是否完善，检查必填项
            return;
        }
        var data = getEditRowData();
        data.newid = Math.random().toString() + new Date().getMilliseconds();   //newid()
        editingNewid = null;    //?进入修改状态，然后点击添加？
        newxmList.unshift(data);   //作为新项添加 //”数组最前端“
        fillDataToGrid();//重新将xm数组呈现至grid
        clearMedicineInfo();//清空药品信息
    }
    
    //修改
    function newtouch_event_f3() {
        if (editingNewid) {
            //提交修改
            var data = getEditRowData();
            if (!(checkEditingRowData())) {    //数据是否完善，检查必填项
                return;
            }
            //检查重复项
            //先在xm数组中找到之
            if (editingNewid) {
                var matchedIndex = -1;
                for (var ii = 0; ii < newxmList.length; ii++) {
                    if (newxmList[ii].newid === data.newid) {
                        matchedIndex = ii;
                        break;
                    }
                }
                if (matchedIndex === -1) {
                    return; //应该是异常
                }
                newxmList.remove(matchedIndex);   //移除该项
                newxmList.unshift(data);   //作为新项添加    //”数组最前端“
            }
            fillDataToGrid();//重新将xm数组呈现至grid
            clearMedicineInfo();//清空药品信息
            bottomButtonsReset();//重置按钮
        } else {
            //获取grid当前选中的那一行
            var seleId = $('#gridList').jqGrid('getGridParam', 'selrow');
            if (seleId) {
                //请求修改该行
                gridEditRow(seleId);
            }
        }
    }

    //删除
    function newtouch_event_f6() {
        var rowid = $("#gridList").jqGrid("getGridParam", "selrow");
        if (rowid) {
            var rowData = $("#gridList").jqGrid('getRowData', rowid);
            if (rowData) {
                if (rowData.newid === editingNewid) {
                    $.modalAlert("该行正在处于编辑状态，不能删除", 'warning');
                    return; //该行正在处于编辑状态，不能删除
                }
                var matchedIndex = -1;
                for (var ii = 0; ii < newxmList.length; ii++) {
                    if (newxmList[ii].newid === rowData.newid) {
                        matchedIndex = ii;
                    }
                }
                if (matchedIndex === -1) {
                    return; //应该是异常
                }
                newxmList.remove(matchedIndex);   //移除该项
                fillDataToGrid();//重新将xm数组呈现至grid
                bottomButtonsReset();
            }
        }
    }

    //新退药单
    function newtouch_event_f7() {
        //禁用退药信息
        var list = new Array();
        list.push({ id: 'tybm' });
        list.push({ id: 'tyrq' });
        list.push({ id: 'fyfs' });
        readonly(list, 2);
        //解锁药品信息
        var list2 = new Array();
        list2.push({ id: 'srm' });
        list2.push({ id: 'pc' });
        list2.push({ id: 'yxq' });
        list2.push({ id: 'tysl' });
        list2.push({ id: 'ty_dw' });
        readonly(list2, 1);
        $("#gridList").clearGridData();
        init();
        $("#tyrq").val($.getDate());
        $("#tybm").val("");
        $("#fyfs").val("");

        newtouch_globalevent_f4(null, {
            container: "#form2",
            inner: false
        });
        newxmList = [];   //新项目List
        editingNewid = null;    //正在修改的行
        bottomButtonsReset();
    }
    
    //退药
    function newtouch_event_f8() {
        if (newxmList.length === 0) {
            $.modalAlert("药品信息不能为空！", 'warning');
            return;
        }
        var par = new Object();

        par["xtYpLsNbfymxk"] = newxmList;
        par["tydh"] = $("#tydh").val();
        par["fyfs"] = $("#fyfs").val();
        par["tybm"] = $("#tybm").val();
        if (newxmList && par["tybm"] && par["tydh"] && par["fyfs"]) {
            $.najax({
                type: "POST",
                url: "/Medicine/ExecHandOutMedicine",
                data: par,
                dataType: "json",
                success: function (res) {
                    if (res.state === "success") {
                        newtouch_event_f7();
                        $.modalMsg('退药成功', 'success', 1000);
                    } else {
                        $.modalAlert(res.message, 'error');
                    }
                }
            });
        }
    }

    ////取消修改
    //function newtouch_event_f8() {
    //    clearMedicineInfo();
    //    editingNewid = null;    //正在修改的行
    //    $("#gridList").resetSelection();
    //    bottomButtonsReset();
    //}

    //按钮重置
    function bottomButtonsReset() {
        $('#btn_bottombutton_f2').removeAttr('disabled');
        $('#btn_bottombutton_f3').attr('disabled', 'disabled');
        $('#btn_bottombutton_f6').attr('disabled', 'disabled');
        $('#btn_bottombutton_f9').hide();
    }

    //清空药品信息
    function clearMedicineInfo() {
        newtouch_globalevent_f4(null, {
            container: "#form2",
            inner: false
        });
        $("#pc").find("option").remove();
        $("#yxq").find("option").remove();
        editingNewid = null;

    }

    //获取编辑域的对象数据
    function getEditRowData() {
        var newData = $("#form1").formSerialize();
        newData["dw"] = $("#ty_dw").find("option:selected").text();
        var tysl = Number($("#tysl").val());
        var zhyz = Number($("#zhyz").val());
        newData["tysl"] = tysl;
        if ($("#ty_dw").val() === "zxdw") {
            newData["fysl"] = tysl / zhyz;
        } else {
            newData["fysl"] = tysl;
        }
        return newData;
    }

    //验证退药信息
    function validatelyInfo() {
        //判断必填
        var validator = $('#form1').validate();
        validator.settings = {
            rules: {
                tybm: { required: true },
                tyrq: { required: true },
                fyfs: { required: true }
            },
            messages: {
                tybm: { required: "退药部门必须填写" },
                tyrq: { required: "退药日期必须选择" },
                fyfs: { required: "退药方式必须选择" }
            },
            showErrors: function (errorMap, errorList) {
                if (!$.isEmptyObject(errorList)) {
                    $.modalAlert(errorList[0].message, 'warning');
                }
            }
        };
        if (!validator.form()) {
            return false;
        }
        return true;
    }

    //检查正在编辑的数据（待提交）的完整性
    function checkEditingRowData() {
        if (validatelyInfo()) {
            var validator = $('#form1').validate();
            validator.settings = {
                rules: {
                    tysl: { required: true, isIntGtZero: true },
                    srm: { required: true },
                    pc: { required: true },
                    yxq: { required: true }
                },
                messages: {
                    tysl: { required: "退药数量必须填写", isIntGtZero: "退药数量必须是大于0的整数" },
                    srm: { required: "药品代码必须填写" },
                    pc: { required: "批次不能为空" },
                    yxq: { required: "有效期不能为空" }
                },
                showErrors: function (errorMap, errorList) {
                    if (!$.isEmptyObject(errorList)) {
                        $.modalAlert(errorList[0].message, 'warning');
                    }
                }
            };
            if (!validator.form()) {
                return false;
            }
            var zxdwsl = 0;
            var tysl = Number($("#tysl").val());
            var zxsl = Number($("#zxsl").val());
            var pfj = Number($("#pfj").val()).toFixed(2);
            var lsj = Number($("#lsj").val()).toFixed(2);
            var zhyz = Number($("#zhyz").val());
            dtdw = $("#ty_dw").find("option:selected").text();
            //1. 检查退药数量
            if ($("#ty_dw").val() === "zxdw") {
                $("#pfje").val((pfj / zhyz * tysl).toFixed(2));
                $("#lsje").val((lsj / zhyz * tysl).toFixed(2));
                zxdwsl = tysl;
            } else {
                $("#pfje").val((tysl * pfj).toFixed(2));
                $("#lsje").val((tysl * lsj).toFixed(2));
                zxdwsl = tysl * zhyz;
            }
            if (zxdwsl > zxsl) {
                $.modalAlert("退货数量不大于可用库存数量！", 'warning');
                $("#tysl").val("");
                $("#tysl").focus();
                return false;
            }
            return true;
        }
        return false;
    }

    function changeval(type) {
        globalpc = globalpc || [];
        var t = type === 'pc' ? 'yxq' : 'pc';
        var val = $("#" + type).val();
        for (var i = 0; i < globalpc.length; i++) {
            if (globalpc[i][type] === val) {
                $('#' + t).val(globalpc[i][t]);
                return;
            }
        }
    }
    
    //禁用软件
    function readonly(list, type) {
        if (list && list.length > 0) {
            for (var i = 0; i < list.length; i++) {
                if (type === 1) {//禁用
                    $("#" + list[i]["id"]).addClass('newtouch_Readonly').attr("disabled", "disabled").css("background-color", "rgb(238,238,238)");
                } else {//启用
                    $("#" + list[i]["id"]).removeClass("newtouch_Readonly").removeAttr("disabled").css("background-color", "");
                }

            }
        }
    }

    function ValidateForm() {
        var tybm = $("#tybm").val();
        var tyrq = $("#tyrq").val();
        var fyfs = $("#fyfs").find("option:selected").text();;
        if (!(tybm || tyrq) || fyfs === "==请选择==") {
            return false;
        }
        //禁用领药信息
        var list = new Array();
        list.push({ id: 'tybm' });
        list.push({ id: 'tyrq' });
        list.push({ id: 'fyfs' });
        readonly(list, 1);
        //解锁药品信息
        var list2 = new Array();
        list2.push({ id: 'srm' });
        //list2.push({ id: 'pc' });
        list2.push({ id: 'yxq' });
        list2.push({ id: 'tysl' });
        list2.push({ id: 'ty_dw' });
        readonly(list2, 2);
        return true;
    }
</script>
